import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

public class User implements HttpSessionBindingListener {

	private String name;
	private UserList ul = UserList.getInstance();

	public User() {
	}

	public User(String name) {
		this.name = name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	@Override
	public void valueBound(HttpSessionBindingEvent event) {
		ul.addUser(name);

	}// 當User對象加入到Session中是，Servlet調用此方法，將用戶名保存到用戶列表

	@Override
	public void valueUnbound(HttpSessionBindingEvent event) {
		ul.removeUser(name);

	}// 當User對象從Session中被刪除時，Servlet調用此方法，將用戶從用戶列表中刪除

}
